/*      */ package gdut.jmxywz.action;
/*      */ 
/*      */ import com.opensymphony.xwork2.ActionContext;
/*      */ import gdut.jmxywz.been.Info;
/*      */ import gdut.jmxywz.been.InfoFiles;
/*      */ import gdut.jmxywz.been.Teacher;
/*      */ import gdut.jmxywz.service.CommonService;
/*      */ import gdut.jmxywz.util.PageModel;
/*      */ import java.io.File;
/*      */ import java.io.FileInputStream;
/*      */ import java.io.FileOutputStream;
/*      */ import java.io.PrintStream;
/*      */ import java.io.UnsupportedEncodingException;
/*      */ import java.net.URLEncoder;
/*      */ import java.text.DateFormat;
/*      */ import java.text.SimpleDateFormat;
/*      */ import java.util.ArrayList;
/*      */ import java.util.Date;
/*      */ import java.util.Iterator;
/*      */ import java.util.List;
/*      */ import java.util.Map;
/*      */ import java.util.Random;
/*      */ import javax.servlet.http.HttpServletRequest;
/*      */ import org.apache.struts2.ServletActionContext;
/*      */ 
/*      */ public class AfficheAction extends BaseAction
/*      */ {
/*      */   private static final String TEACHER_SESSION_KEY = "teacherSessionKey";
/*      */   private Info info;
/*      */   private Teacher teacher;
/*      */   private String errorMessage;
/*   30 */   private String where_search = "";
/*      */   private String where_value;
/*      */   private String like;
/*   33 */   private String searchWhere = "";
/*      */   private String[] files_content;
/*      */   private String[] files_title;
/*      */   private List<File> upload_file;
/*      */   private String[] files_save_as;
/*      */   private String[] upload_fileContentType;
/*      */   private String[] upload_fileFileName;
/*      */   private String savePath;
/*      */   private List<InfoFiles> infoFiles;
/*   48 */   private int currentPage = 1;
/*   49 */   private int pageSize = 5;
/*      */   private String nextPage;
/*      */   private PageModel pm;
/*      */ 
/*      */   public Info getInfo()
/*      */   {
/*   57 */     return this.info;
/*      */   }
/*      */   public void setInfo(Info info) {
/*   60 */     this.info = info;
/*      */   }
/*      */ 
/*      */   public Teacher getTeacher() {
/*   64 */     return this.teacher;
/*      */   }
/*      */   public void setTeacher(Teacher teacher) {
/*   67 */     this.teacher = teacher;
/*      */   }
/*      */   public String getWhere_search() {
/*   70 */     return this.where_search;
/*      */   }
/*      */   public void setWhere_search(String whereSearch) {
/*   73 */     this.where_search = whereSearch;
/*      */   }
/*      */   public String getWhere_value() {
/*   76 */     return this.where_value;
/*      */   }
/*      */ 
/*      */   public void setWhere_value(String where_value) throws UnsupportedEncodingException {
/*   80 */     this.where_value = new String(where_value.getBytes("ISO-8859-1"), "utf-8");
/*      */   }
/*      */ 
/*      */   public String getLike() {
/*   84 */     return this.like;
/*      */   }
/*      */   public void setLike(String like) {
/*   87 */     this.like = like;
/*      */   }
/*      */   public String getSearch() {
/*   90 */     return this.where_search;
/*      */   }
/*      */   public void setSearch(String where_search) {
/*   93 */     this.where_search = where_search;
/*      */   }
/*      */ 
/*      */   public String getSearchWhere() {
/*   97 */     return this.searchWhere;
/*      */   }
/*      */   public void setSearchWhere(String searchWhere) {
/*  100 */     this.searchWhere = searchWhere;
/*      */   }
/*      */ 
/*      */   public String[] getFiles_content()
/*      */   {
/*  105 */     return this.files_content;
/*      */   }
/*      */   public void setFiles_content(String[] filesContent) {
/*  108 */     this.files_content = filesContent;
/*      */   }
/*      */   public String[] getFiles_title() {
/*  111 */     return this.files_title;
/*      */   }
/*      */   public void setFiles_title(String[] filesTitle) {
/*  114 */     this.files_title = filesTitle;
/*      */   }
/*      */   public List<File> getUpload_file() {
/*  117 */     return this.upload_file;
/*      */   }
/*      */   public void setUpload_file(List<File> uploadFile) {
/*  120 */     this.upload_file = uploadFile;
/*      */   }
/*      */   public String[] getFiles_save_as() {
/*  123 */     return this.files_save_as;
/*      */   }
/*      */   public void setFiles_save_as(String[] filesSaveAs) {
/*  126 */     this.files_save_as = filesSaveAs;
/*      */   }
/*      */   public String[] getUpload_fileContentType() {
/*  129 */     return this.upload_fileContentType;
/*      */   }
/*      */   public void setUpload_fileContentType(String[] uploadFileContentType) {
/*  132 */     this.upload_fileContentType = uploadFileContentType;
/*      */   }
/*      */   public String[] getUpload_fileFileName() {
/*  135 */     return this.upload_fileFileName;
/*      */   }
/*      */   public void setUpload_fileFileName(String[] uploadFileFileName) {
/*  138 */     this.upload_fileFileName = uploadFileFileName;
/*      */   }
/*      */   public String getSavePath() {
/*  141 */     return ServletActionContext.getRequest().getRealPath(this.savePath);
/*      */   }
/*      */   public void setSavePath(String savePath) {
/*  144 */     this.savePath = savePath;
/*      */   }
/*      */   public List<InfoFiles> getInfoFiles() {
/*  147 */     return this.infoFiles;
/*      */   }
/*      */   public void setInfoFiles(List<InfoFiles> infoFiles) {
/*  150 */     this.infoFiles = infoFiles;
/*      */   }
/*      */ 
/*      */   public int getPageSize()
/*      */   {
/*  157 */     return this.pageSize;
/*      */   }
/*      */   public void setPageSize(int pageSize) {
/*  160 */     this.pageSize = pageSize;
/*      */   }
/*      */   public String getNextPage() {
/*  163 */     return this.nextPage;
/*      */   }
/*      */   public void setNextPage(String nextPage) {
/*  166 */     this.nextPage = nextPage;
/*      */   }
/*      */   public int getCurrentPage() {
/*  169 */     return this.currentPage;
/*      */   }
/*      */   public void setCurrentPage(int currentPage) {
/*  172 */     this.currentPage = currentPage;
/*      */   }
/*      */   public PageModel getPm() {
/*  175 */     return this.pm;
/*      */   }
/*      */   public void setPm(PageModel pm) {
/*  178 */     this.pm = pm;
/*      */   }
/*      */ 
/*      */   public String getErrorMessage() {
/*  182 */     return this.errorMessage;
/*      */   }
/*      */   public void setErrorMessage(String errorMessage) {
/*  185 */     this.errorMessage = errorMessage;
/*      */   }
/*      */ 
/*      */   public String Add()
/*      */     throws Exception
/*      */   {
/*  194 */     this.teacher = ((Teacher)ActionContext.getContext().getSession().get("teacherSessionKey"));
/*      */ 
/*  196 */     List files = getUpload_file();
/*      */ 
/*  198 */     List file_list = new ArrayList();
/*  199 */     setSavePath("");
/*  200 */     boolean bl = false;
/*  201 */     boolean b2 = false;
/*      */ 
/*  203 */     System.out.println("==================");
/*      */ 
/*  205 */     System.out.println(this.info.getInfoTime());
/*      */ 
/*  207 */     this.info.setTeacherByInfoEditer(this.teacher);
/*      */ 
/*  209 */     if (("".equals(this.info.getInfoTitle())) || ("".equals(this.info.getInfoContext())) || ("".equals(this.info.getInfoSender())))
/*      */     {
/*  211 */       this.errorMessage = "发布的信息不符合要求！请修改！";
/*  212 */       return "error";
/*      */     }
/*      */ 
/*  216 */     bl = getCommonService().saveObject(this.info);
/*      */ 
/*  220 */     if (files != null) {
/*  221 */       for (int i = 0; i < files.size(); i++) {
/*  222 */         String extend_name = getUpload_fileFileName()[i];
/*  223 */         System.out.println(extend_name);
/*  224 */         int extend_name_int = extend_name.lastIndexOf(".");
/*  225 */         extend_name = extend_name.substring(extend_name_int);
/*      */ 
/*  227 */         DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
/*  228 */         String datestr = df.format(new Date());
/*  229 */         Random rand = new Random();
/*  230 */         int ram = rand.nextInt(500);
/*  231 */         String ram_str = String.valueOf(ram);
/*  232 */         for (int i_i = 0; ram_str.length() < 6; i_i++) {
/*  233 */           ram_str = "0" + ram_str;
/*      */         }
/*      */ 
/*  236 */         extend_name = datestr + ram_str + extend_name;
/*  237 */         String Save_path = "\\affficheFiles\\" + extend_name;
/*  238 */         FileOutputStream fos = new FileOutputStream(getSavePath() + Save_path);
/*      */ 
/*  240 */         FileInputStream fis = new FileInputStream((File)files.get(i));
/*  241 */         byte[] buffer = new byte[1024];
/*  242 */         int len = 0;
/*  243 */         while ((len = fis.read(buffer)) > 0) {
/*  244 */           fos.write(buffer, 0, len);
/*      */         }
/*      */ 
/*  248 */         InfoFiles afiles = new InfoFiles();
/*      */ 
/*  251 */         System.out.println();
/*  252 */         System.out.println("----------第--" + (i + 1) + "--文件--------------");
/*  253 */         System.out.println("----服务器保存路径-:---" + Save_path + "--------------");
/*  254 */         System.out.println("--------文件名:" + this.files_title[i] + "--------------");
/*  255 */         System.out.println("--------文件说明:" + this.files_content[i] + "--------------");
/*      */ 
/*  257 */         afiles.setFileUrl(Save_path);
/*  258 */         afiles.setFileName(this.files_title[i]);
/*  259 */         afiles.setFileContext(this.files_content[i]);
/*  260 */         afiles.setInfo(this.info);
/*      */ 
/*  263 */         b2 = getCommonService().saveObject(afiles);
/*      */       }
/*      */ 
/*      */     }
/*      */ 
/*  269 */     if (bl)
/*      */     {
/*  271 */       return "AfficheAdd";
/*      */     }
/*  273 */     return "error";
/*      */   }
/*      */ 
/*      */   public String List()
/*      */     throws Exception
/*      */   {
/*  284 */     String hql = " from Info where  infoType=1 and auditing in(1,2)";
/*      */ 
/*  286 */     String[] parem = (String[])null;
/*      */ 
/*  288 */     String search_parameter = "";
/*  289 */     String en_where_value = "";
/*      */ 
/*  292 */     this.nextPage = "afficheList.action";
/*      */ 
/*  294 */     if ((!"".equals(this.where_value)) && (this.where_value != null))
/*      */     {
/*  296 */       en_where_value = URLEncoder.encode(this.where_value, "utf-8");
/*  297 */       System.out.println("++++-- " + this.where_value);
/*      */ 
/*  299 */       if (this.like.equals("like"))
/*      */       {
/*  301 */         hql = hql + "and " + this.where_search + " like '%" + this.where_value + "%'";
/*      */       }
/*  303 */       else hql = hql + "and  " + this.where_search + " = '" + this.where_value + "'";
/*      */ 
/*      */     }
/*      */ 
/*  308 */     hql = hql + " order by infoTime desc,infoId desc";
/*      */ 
/*  312 */     search_parameter = "&where_search=" + this.where_search + "&like=" + this.like + "&where_value=" + en_where_value;
/*      */ 
/*  314 */     this.pm = new PageModel();
/*      */ 
/*  316 */     this.pm = getCommonService().findPage(hql, parem, this.currentPage, this.pageSize, this.nextPage, search_parameter);
/*      */ 
/*  318 */     return "AfficheList";
/*      */   }
/*      */ 
/*      */   public String List1() throws Exception
/*      */   {
/*  323 */     String hql = " from Info where  infoType=1 and auditing in(1,2)";
/*      */ 
/*  325 */     String[] parem = (String[])null;
/*      */ 
/*  327 */     String search_parameter = "";
/*  328 */     String en_where_value = "";
/*      */ 
/*  331 */     this.nextPage = "afficheList1.action";
/*      */ 
/*  333 */     if ((!"".equals(this.where_value)) && (this.where_value != null))
/*      */     {
/*  335 */       en_where_value = URLEncoder.encode(this.where_value, "utf-8");
/*  336 */       System.out.println("++++-- " + this.where_value);
/*      */ 
/*  338 */       if (this.like.equals("like"))
/*      */       {
/*  340 */         hql = hql + "and " + this.where_search + " like '%" + this.where_value + "%'";
/*      */       }
/*  342 */       else hql = hql + "and  " + this.where_search + " = '" + this.where_value + "'";
/*      */ 
/*      */     }
/*      */ 
/*  347 */     hql = hql + " order by infoTime desc,infoId desc";
/*      */ 
/*  351 */     search_parameter = "&where_search=" + this.where_search + "&like=" + this.like + "&where_value=" + en_where_value;
/*      */ 
/*  353 */     this.pm = new PageModel();
/*      */ 
/*  355 */     this.pm = getCommonService().findPage(hql, parem, this.currentPage, this.pageSize, this.nextPage, search_parameter);
/*      */ 
/*  357 */     return "AfficheList1";
/*      */   }
/*      */ 
/*      */   public String ListSelf()
/*      */     throws Exception
/*      */   {
/*  368 */     this.teacher = ((Teacher)ActionContext.getContext().getSession().get("teacherSessionKey"));
/*      */ 
/*  370 */     String hql = " from Info info where  info.infoType=1 and info.teacherByInfoEditer.teacherId=" + this.teacher.getTeacherId();
/*      */ 
/*  372 */     String[] parem = (String[])null;
/*      */ 
/*  374 */     String search_parameter = "";
/*  375 */     String en_where_value = "";
/*      */ 
/*  378 */     this.nextPage = "afficheListSelf.action";
/*      */ 
/*  380 */     if ((!"".equals(this.where_value)) && (this.where_value != null)) {
/*  381 */       en_where_value = URLEncoder.encode(this.where_value, "utf-8");
/*      */ 
/*  383 */       System.out.println("++++-- " + this.where_value);
/*  384 */       if (this.like.equals("like"))
/*      */       {
/*  386 */         hql = hql + "and " + this.where_search + " like '%" + this.where_value + "%'";
/*      */       }
/*      */       else
/*      */       {
/*  390 */         hql = hql + "and  " + this.where_search + " = '" + this.where_value + "'";
/*      */       }
/*      */ 
/*      */     }
/*      */ 
/*  397 */     search_parameter = "&where_search=" + this.where_search + "&like=" + this.like + "&where_value=" + en_where_value;
/*      */ 
/*  399 */     hql = hql + " order by infoTime desc,infoId desc";
/*      */ 
/*  401 */     this.pm = new PageModel();
/*      */ 
/*  403 */     this.pm = getCommonService().findPage(hql, parem, this.currentPage, this.pageSize, this.nextPage, search_parameter);
/*      */ 
/*  405 */     return "AfficheListSelf";
/*      */   }
/*      */ 
/*      */   public String ListSelf1()
/*      */     throws Exception
/*      */   {
/*  411 */     this.teacher = ((Teacher)ActionContext.getContext().getSession().get("teacherSessionKey"));
/*      */ 
/*  413 */     String hql = " from Info info where  info.infoType=1 and info.teacherByInfoEditer.teacherId=" + this.teacher.getTeacherId();
/*      */ 
/*  415 */     String[] parem = (String[])null;
/*      */ 
/*  417 */     String search_parameter = "";
/*  418 */     String en_where_value = "";
/*      */ 
/*  421 */     this.nextPage = "afficheListSelf1.action";
/*      */ 
/*  423 */     if ((!"".equals(this.where_value)) && (this.where_value != null)) {
/*  424 */       en_where_value = URLEncoder.encode(this.where_value, "utf-8");
/*      */ 
/*  426 */       System.out.println("++++-- " + this.where_value);
/*  427 */       if (this.like.equals("like"))
/*      */       {
/*  429 */         hql = hql + "and " + this.where_search + " like '%" + this.where_value + "%'";
/*      */       }
/*      */       else
/*      */       {
/*  433 */         hql = hql + "and  " + this.where_search + " = '" + this.where_value + "'";
/*      */       }
/*      */ 
/*      */     }
/*      */ 
/*  440 */     search_parameter = "&where_search=" + this.where_search + "&like=" + this.like + "&where_value=" + en_where_value;
/*      */ 
/*  442 */     hql = hql + " order by infoTime desc,infoId desc";
/*      */ 
/*  444 */     this.pm = new PageModel();
/*      */ 
/*  446 */     this.pm = getCommonService().findPage(hql, parem, this.currentPage, this.pageSize, this.nextPage, search_parameter);
/*      */ 
/*  448 */     return "AfficheListSelf1";
/*      */   }
/*      */ 
/*      */   public String Detail()
/*      */     throws Exception
/*      */   {
/*  461 */     String hql = "from InfoFiles where infoId = " + this.info.getInfoId();
/*      */ 
/*  464 */     this.info = ((Info)getCommonService().findByIntId(this.info.getInfoId().intValue(), "gdut.jmxywz.been.Info"));
/*      */ 
/*  466 */     this.info.setInfoReadtimes(Integer.valueOf(this.info.getInfoReadtimes().intValue() + 1));
/*      */ 
/*  468 */     getCommonService().updateObject(this.info);
/*      */ 
/*  471 */     this.infoFiles = getCommonService().findListByHql(hql, null);
/*      */ 
/*  476 */     return "AfficheDetail";
/*      */   }
/*      */ 
/*      */   public String Auditing()
/*      */     throws Exception
/*      */   {
/*  488 */     String hql = "from Info where infoType = 1";
/*  489 */     String[] parem = (String[])null;
/*  490 */     String search_parameter = "";
/*  491 */     String swhere_value = this.where_value;
/*      */ 
/*  493 */     String en_where_value = "";
/*  494 */     if ((!"".equals(this.where_value)) && (this.where_value != null))
/*      */     {
/*  497 */       if (this.like.equals("like"))
/*      */       {
/*  500 */         System.out.println("fanhuid == " + this.where_value);
/*  501 */         hql = hql + "and " + this.where_search + " like '%" + swhere_value + "%'";
/*  502 */         System.out.println("====++++" + this.where_value);
/*  503 */         en_where_value = URLEncoder.encode(this.where_value, "utf-8");
/*      */       }
/*      */       else
/*      */       {
/*  509 */         hql = hql + "and " + this.where_search + " = '" + this.where_value + "'";
/*      */ 
/*  511 */         en_where_value = URLEncoder.encode(this.where_value, "utf-8");
/*      */       }
/*      */ 
/*  514 */       System.out.println("------------++ " + search_parameter);
/*      */     }
/*      */ 
/*  517 */     if ((this.info == null) || (this.info.getAuditing() == null))
/*      */     {
/*  519 */       this.nextPage = "afficheAuditing.action";
/*      */ 
/*  522 */       hql = hql + " order by auditing asc ,infoTime desc, infoId desc ";
/*      */     }
/*      */     else
/*      */     {
/*  526 */       hql = hql + "and auditing=" + this.info.getAuditing() + "order by  auditing  asc ,infoTime desc,infoId desc  ";
/*  527 */       this.nextPage = "afficheAuditing.action?info.auditing=0&";
/*      */     }
/*      */ 
/*  530 */     System.out.println("=============  " + this.where_value);
/*  531 */     System.out.println("============= " + this.where_search);
/*  532 */     System.out.println("------------- " + this.like);
/*      */ 
/*  535 */     search_parameter = "&where_search=" + this.where_search + "&like=" + this.like + "&where_value=" + en_where_value;
/*      */ 
/*  537 */     System.out.println("---" + search_parameter);
/*  538 */     System.out.println("---" + hql);
/*      */ 
/*  540 */     this.pm = new PageModel();
/*      */ 
/*  542 */     System.out.println("hql222---" + hql);
/*      */ 
/*  544 */     this.pm = getCommonService().findPage(hql, parem, this.currentPage, this.pageSize, this.nextPage, search_parameter);
/*      */ 
/*  546 */     System.out.println("---------------------" + this.pm.getTotalCount());
/*      */ 
/*  551 */     return "AfficheAuditing";
/*      */   }
/*      */ 
/*      */   public String Auditing1() throws Exception
/*      */   {
/*  556 */     String hql = "from Info where infoType = 1";
/*  557 */     String[] parem = (String[])null;
/*  558 */     String search_parameter = "";
/*  559 */     String swhere_value = this.where_value;
/*      */ 
/*  561 */     String en_where_value = "";
/*  562 */     if ((!"".equals(this.where_value)) && (this.where_value != null))
/*      */     {
/*  565 */       if (this.like.equals("like"))
/*      */       {
/*  568 */         System.out.println("fanhuid == " + this.where_value);
/*  569 */         hql = hql + "and " + this.where_search + " like '%" + swhere_value + "%'";
/*  570 */         System.out.println("====++++" + this.where_value);
/*  571 */         en_where_value = URLEncoder.encode(this.where_value, "utf-8");
/*      */       }
/*      */       else
/*      */       {
/*  577 */         hql = hql + "and " + this.where_search + " = '" + this.where_value + "'";
/*      */ 
/*  579 */         en_where_value = URLEncoder.encode(this.where_value, "utf-8");
/*      */       }
/*      */ 
/*  582 */       System.out.println("------------++ " + search_parameter);
/*      */     }
/*      */ 
/*  585 */     if ((this.info == null) || (this.info.getAuditing() == null))
/*      */     {
/*  587 */       this.nextPage = "afficheAuditing1.action";
/*      */ 
/*  590 */       hql = hql + " order by auditing asc ,infoTime desc, infoId desc ";
/*      */     }
/*      */     else
/*      */     {
/*  594 */       hql = hql + "and auditing=" + this.info.getAuditing() + "order by  auditing  asc ,infoTime desc,infoId desc  ";
/*  595 */       this.nextPage = "afficheAuditing1.action?info.auditing=0&";
/*      */     }
/*      */ 
/*  598 */     System.out.println("=============  " + this.where_value);
/*  599 */     System.out.println("============= " + this.where_search);
/*  600 */     System.out.println("------------- " + this.like);
/*      */ 
/*  603 */     search_parameter = "&where_search=" + this.where_search + "&like=" + this.like + "&where_value=" + en_where_value;
/*      */ 
/*  605 */     System.out.println("---" + search_parameter);
/*  606 */     System.out.println("---" + hql);
/*      */ 
/*  608 */     this.pm = new PageModel();
/*      */ 
/*  610 */     System.out.println("hql222---" + hql);
/*      */ 
/*  612 */     this.pm = getCommonService().findPage(hql, parem, this.currentPage, this.pageSize, this.nextPage, search_parameter);
/*      */ 
/*  614 */     System.out.println("---------------------" + this.pm.getTotalCount());
/*      */ 
/*  619 */     return "AfficheAuditing1";
/*      */   }
/*      */ 
/*      */   public String Inside()
/*      */     throws Exception
/*      */   {
/*  629 */     this.teacher = ((Teacher)ActionContext.getContext().getSession().get("teacherSessionKey"));
/*      */ 
/*  631 */     this.info = ((Info)getCommonService().findByIntId(this.info.getInfoId().intValue(), "gdut.jmxywz.been.Info"));
/*      */ 
/*  633 */     this.info.setAuditing("1");
/*      */ 
/*  635 */     this.info.setTeacherByInfoAssessor(this.teacher);
/*      */ 
/*  637 */     getCommonService().updateObject(this.info);
/*      */ 
/*  640 */     return "AfficheInside";
/*      */   }
/*      */ 
/*      */   public String Outside()
/*      */     throws Exception
/*      */   {
/*  649 */     this.teacher = ((Teacher)ActionContext.getContext().getSession().get("teacherSessionKey"));
/*      */ 
/*  651 */     this.info = ((Info)getCommonService().findByIntId(this.info.getInfoId().intValue(), "gdut.jmxywz.been.Info"));
/*      */ 
/*  653 */     this.info.setAuditing("2");
/*  654 */     this.info.setTeacherByInfoAssessor(this.teacher);
/*      */ 
/*  656 */     getCommonService().updateObject(this.info);
/*      */ 
/*  658 */     return "AfficheOutside";
/*      */   }
/*      */ 
/*      */   public String Notallow()
/*      */     throws Exception
/*      */   {
/*  667 */     this.teacher = ((Teacher)ActionContext.getContext().getSession().get("teacherSessionKey"));
/*      */ 
/*  669 */     this.info = ((Info)getCommonService().findByIntId(this.info.getInfoId().intValue(), "gdut.jmxywz.been.Info"));
/*      */ 
/*  671 */     this.info.setAuditing("3");
/*      */ 
/*  673 */     this.info.setTeacherByInfoAssessor(this.teacher);
/*      */ 
/*  675 */     getCommonService().updateObject(this.info);
/*      */ 
/*  677 */     return "AfficheNotallow";
/*      */   }
/*      */ 
/*      */   public String Rollback()
/*      */     throws Exception
/*      */   {
/*  689 */     this.teacher = ((Teacher)ActionContext.getContext().getSession().get("teacherSessionKey"));
/*      */ 
/*  691 */     String hql = "from InfoFiles where infoId=?";
/*      */ 
/*  694 */     this.info = ((Info)getCommonService().findByIntId(this.info.getInfoId().intValue(), "gdut.jmxywz.been.Info"));
/*      */ 
/*  696 */     this.info.setAuditing("0");
/*  697 */     this.info.setTeacherByInfoAssessor(this.teacher);
/*      */ 
/*  699 */     getCommonService().updateObject(this.info);
/*      */ 
/*  701 */     return "AfficheRollback";
/*      */   }
/*      */ 
/*      */   public String ModifySelfShow()
/*      */     throws Exception
/*      */   {
/*  714 */     this.teacher = ((Teacher)ActionContext.getContext().getSession().get("teacherSessionKey"));
/*      */ 
/*  716 */     String hql = "from InfoFiles file where file.info.infoId= " + this.info.getInfoId();
/*      */ 
/*  718 */     this.info = ((Info)getCommonService().findByIntId(this.info.getInfoId().intValue(), "gdut.jmxywz.been.Info"));
/*      */ 
/*  720 */     if (!this.info.getTeacherByInfoEditer().getTeacherId().equals(this.teacher.getTeacherId()))
/*      */     {
/*  722 */       System.out.println("没有修改的权限");
/*      */ 
/*  724 */       return "error";
/*      */     }
/*  726 */     if (!"0".equals(this.info.getAuditing()))
/*      */     {
/*  728 */       System.out.println("已通过审核，不能在修改！");
/*      */ 
/*  730 */       return "error";
/*      */     }
/*  732 */     System.out.println("-------------" + this.info.getInfoTitle());
/*      */ 
/*  736 */     this.infoFiles = getCommonService().findListByHql(hql, null);
/*      */ 
/*  738 */     Iterator iter = this.infoFiles.iterator();
/*  739 */     while (iter.hasNext())
/*      */     {
/*  741 */       InfoFiles in = (InfoFiles)iter.next();
/*      */ 
/*  743 */       System.out.println("infoFiles ----" + in.getFileName());
/*      */     }
/*      */ 
/*  746 */     return "AfficheModifyShowSelf";
/*      */   }
/*      */ 
/*      */   public String ModifyShow()
/*      */     throws Exception
/*      */   {
/*  758 */     String hql = "from InfoFiles file where file.info.infoId= " + this.info.getInfoId();
/*      */ 
/*  760 */     this.info = ((Info)getCommonService().findByIntId(this.info.getInfoId().intValue(), "gdut.jmxywz.been.Info"));
/*      */ 
/*  762 */     System.out.println("-------------" + this.info.getInfoTitle());
/*      */ 
/*  766 */     this.infoFiles = getCommonService().findListByHql(hql, null);
/*  767 */     Iterator iter = this.infoFiles.iterator();
/*  768 */     while (iter.hasNext()) {
/*  769 */       InfoFiles in = (InfoFiles)iter.next();
/*      */ 
/*  771 */       System.out.println("infoFiles ----" + in.getFileName());
/*      */     }
/*      */ 
/*  774 */     return "AfficheModifyShow";
/*      */   }
/*      */ 
/*      */   public String Modify()
/*      */     throws Exception
/*      */   {
/*  788 */     List files = getUpload_file();
/*      */ 
/*  790 */     List file_list = new ArrayList();
/*  791 */     setSavePath("");
/*  792 */     boolean bl = false;
/*  793 */     boolean b2 = false;
/*      */ 
/*  797 */     System.out.println("---Modify---" + this.info.getInfoTitle());
/*  798 */     System.out.println("---ModifyId---" + this.info.getInfoId());
/*      */ 
/*  800 */     Info info1 = (Info)getCommonService().findByIntId(this.info.getInfoId().intValue(), "gdut.jmxywz.been.Info");
/*      */ 
/*  802 */     info1.setInfoTitle(this.info.getInfoTitle());
/*  803 */     info1.setInfoContext(this.info.getInfoContext());
/*  804 */     info1.setInfoSender(this.info.getInfoSender());
/*  805 */     info1.setInfoTime(this.info.getInfoTime());
/*  806 */     info1.setAuditing(info1.getAuditing());
/*  807 */     info1.setAssessorInfo(this.info.getAssessorInfo());
/*  808 */     info1.setTeacherByInfoAssessor(this.info.getTeacherByInfoAssessor());
/*  809 */     info1.setTeacherByInfoEditer(this.info.getTeacherByInfoEditer());
/*      */ 
/*  813 */     if (("".equals(info1.getInfoTitle())) || ("".equals(info1.getInfoContext())) || ("".equals(info1.getInfoSender())))
/*      */     {
/*  815 */       return "error";
/*      */     }
/*  817 */     bl = getCommonService().updateObject(info1);
/*      */ 
/*  820 */     System.out.println("===" + this.files_content);
/*  821 */     System.out.println("==" + this.files_title);
/*  822 */     if (files != null) {
/*  823 */       for (int i = 0; i < files.size(); i++) {
/*  824 */         String extend_name = getUpload_fileFileName()[i];
/*  825 */         System.out.println(extend_name);
/*  826 */         int extend_name_int = extend_name.lastIndexOf(".");
/*  827 */         extend_name = extend_name.substring(extend_name_int);
/*      */ 
/*  829 */         DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
/*  830 */         String datestr = df.format(new Date());
/*  831 */         Random rand = new Random();
/*  832 */         int ram = rand.nextInt(500);
/*  833 */         String ram_str = String.valueOf(ram);
/*  834 */         for (int i_i = 0; ram_str.length() < 6; i_i++) {
/*  835 */           ram_str = "0" + ram_str;
/*      */         }
/*      */ 
/*  838 */         extend_name = datestr + ram_str + extend_name;
/*  839 */         String Save_path = "\\affficheFiles\\" + extend_name;
/*  840 */         FileOutputStream fos = new FileOutputStream(getSavePath() + Save_path);
/*      */ 
/*  842 */         FileInputStream fis = new FileInputStream((File)files.get(i));
/*  843 */         byte[] buffer = new byte[1024];
/*  844 */         int len = 0;
/*  845 */         while ((len = fis.read(buffer)) > 0) {
/*  846 */           fos.write(buffer, 0, len);
/*      */         }
/*      */ 
/*  850 */         InfoFiles afiles = new InfoFiles();
/*      */ 
/*  852 */         System.out.println();
/*  853 */         System.out.println("----------第--" + (i + 1) + "--文件--------------");
/*  854 */         System.out.println("----服务器保存路径-:---" + Save_path + "--------------");
/*  855 */         System.out.println("--------文件名:" + this.files_title[i] + "--------------");
/*  856 */         System.out.println("--------文件说明:" + this.files_content[i] + "--------------");
/*      */ 
/*  858 */         afiles.setFileUrl(Save_path);
/*  859 */         afiles.setFileName(this.files_title[i]);
/*  860 */         afiles.setFileContext(this.files_content[i]);
/*  861 */         afiles.setInfo(this.info);
/*      */ 
/*  864 */         b2 = getCommonService().saveObject(afiles);
/*      */       }
/*      */ 
/*      */     }
/*      */ 
/*  870 */     if (bl)
/*      */     {
/*  872 */       return "AfficheModify";
/*      */     }
/*  874 */     return "error";
/*      */   }
/*      */ 
/*      */   public String DeleteSelf()
/*      */     throws Exception
/*      */   {
/*  884 */     this.teacher = ((Teacher)ActionContext.getContext().getSession().get("teacherSessionKey"));
/*      */ 
/*  886 */     String hql = "from InfoFiles  infofiles where infofiles.info.infoId =" + this.info.getInfoId();
/*      */ 
/*  888 */     Info info1 = new Info();
/*      */ 
/*  890 */     info1 = (Info)getCommonService().findByIntId(this.info.getInfoId().intValue(), "gdut.jmxywz.been.Info");
/*      */ 
/*  894 */     if (!info1.getTeacherByInfoEditer().getTeacherId().equals(this.teacher.getTeacherId()))
/*      */     {
/*  896 */       System.out.println("没有删除的权限");
/*      */ 
/*  898 */       return "error";
/*      */     }
/*  900 */     System.out.println("====" + info1.getAuditing());
/*  901 */     if (!"0".equals(info1.getAuditing()))
/*      */     {
/*  903 */       System.out.println("已通过审核，不能再删除！");
/*      */ 
/*  905 */       return "error";
/*      */     }
/*      */ 
/*  910 */     List fileList = getCommonService().findListByHql(hql, null);
/*      */ 
/*  912 */     Iterator iter = fileList.iterator();
/*      */ 
/*  914 */     while (iter.hasNext())
/*      */     {
/*  916 */       InfoFiles infofiles = (InfoFiles)iter.next();
/*      */ 
/*  918 */       String path = ServletActionContext.getRequest().getRealPath("/");
/*      */ 
/*  920 */       path = path + infofiles.getFileUrl();
/*      */ 
/*  922 */       System.out.println("=======" + path);
/*      */ 
/*  924 */       getCommonService().deleteObject(infofiles);
/*      */ 
/*  926 */       deleteFile(path);
/*      */ 
/*  928 */       System.out.println("===文件删除===");
/*      */     }
/*      */ 
/*  932 */     boolean b = getCommonService().deleteObject(info1);
/*  933 */     if (b) {
/*  934 */       return "AfficheDeleteSelf";
/*      */     }
/*  936 */     return "error";
/*      */   }
/*      */ 
/*      */   public String Delete()
/*      */     throws Exception
/*      */   {
/*  947 */     this.teacher = ((Teacher)ActionContext.getContext().getSession().get("teacherSessionKey"));

System.out.println("--------- " + this.info.getInfoId());

String hql = "from InfoFiles  infofiles where infofiles.info.infoId =" + this.info.getInfoId();

this.info = ((Info)getCommonService().findByIntId(this.info.getInfoId().intValue(), "gdut.jmxywz.been.Info"));

List fileList = getCommonService().findListByHql(hql, null);

Iterator iter = fileList.iterator();

while (iter.hasNext())
{
  InfoFiles infofiles = (InfoFiles)iter.next();

  String path = ServletActionContext.getRequest().getRealPath("/");

  path = path + infofiles.getFileUrl();

  System.out.println("=======" + path);

  getCommonService().deleteObject(infofiles);

  deleteFile(path);

  System.out.println("===文件删除===");
}

boolean b = getCommonService().deleteObject(this.info);

System.out.println("-----infoType--" + this.info.getInfoType());
if (b) {
  return "AfficheDelete";
}
return "error";
/*      */   }
/*      */ 
/*      */   public boolean deleteFile(String sPath)
/*      */   {
/* 1000 */     boolean flag = false;
/* 1001 */     File file = new File(sPath);
/*      */ 
/* 1003 */     if ((file.isFile()) && (file.exists())) {
/* 1004 */       file.delete();
/* 1005 */       System.out.println("---成功从服务器删除文件---");
/* 1006 */       flag = true;
/*      */     }
/* 1008 */     return flag;
/*      */   }
/*      */ }

/* Location:           E:\我的项目\经贸学院电子政务\pagemodify\服务器端下载\1.17\
 * Qualified Name:     gdut.jmxywz.action.AfficheAction
 * JD-Core Version:    0.6.0
 */